package com.example.petplanet.controller;

import com.example.petplanet.result.Result;
import com.example.petplanet.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/comment")
public class CommentController {
    private final CommentService commentService;

    public CommentController(CommentService commentService) {
        this.commentService = commentService;
    }

    @GetMapping("/getCommentFromContent/{contentId}")
    public Result<Object> getCommentFromContent(@PathVariable Long contentId){
        return commentService.getCommentFromContent(contentId);
    }

    @PostMapping("publishComment")
    public Result<Object> publishComment(@RequestParam Long replyId,
                                         @RequestParam Long parentId,
                                         @RequestParam String comment,
                                         @RequestParam Long contentId) {
        return commentService.publishComment(comment,contentId,replyId,parentId);
    }

    @DeleteMapping("deleteMyComment")
    public Result<Object> deleteMyComment(@RequestParam Long commentId){
        return commentService.deleteMyComment(commentId);
    }

    @GetMapping("/getCommentById")
    public Result<Object> getCommentById(@RequestParam Long commentId){
        return commentService.getCommentById(commentId);
    }

    //初始化和同步还没写
    @PostMapping("/likeComment")
    public Result<Object> likeComment(@RequestParam Long commentId) {
        return commentService.likeComment(commentId);
    }

    @DeleteMapping("/cancelLikeComment")
    public Result<Object> cancelLikeComment(@RequestParam Long commentId) {
        return commentService.cancelLikeComment(commentId);
    }

}

